﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Dual licensed under the MIT and GPL licenses:
//  http://www.opensource.org/licenses/mit-license.php
//  http://www.gnu.org/licenses/gpl.html

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//using DNA.Mvc.Models;
using System.Web.Mvc;

namespace DNA.Mvc.UI
{
    public class WidgetViewBuilder:ViewComponentBuilder<WidgetView,WidgetViewBuilder>
    {
        public WidgetViewBuilder(WidgetView view, ViewContext context, IViewDataContainer container) : base(view, context, container) { }

        /// <summary>
        /// Set Widget UserPreferences form template
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public WidgetViewBuilder UserPreferences(Action<WidgetHelper> content)
        {
            Component.UserPreferencesTemplate.Content = content;
            return this;
        }
        
        /// <summary>
        /// Set Widget UserPreferences form template
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public WidgetViewBuilder UserPreferences(Func<WidgetHelper,object> content)
        {
            Component.UserPreferencesTemplate.InlineContent = content;
            return this;
        }

        /// <summary>
        /// Set Widget Content template
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public WidgetViewBuilder Content(Action<WidgetHelper> content)
        {
            Component.ContentTemplate.Content = content;
            return this;
        }

        /// <summary>
        /// Set Widget Content template
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public WidgetViewBuilder Content(Func<WidgetHelper,object> content)
        {
            Component.ContentTemplate.InlineContent = content;
            return this;
        }

        /// <summary>
        /// Set Widget Content show in design time.
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public WidgetViewBuilder Design(Func<WidgetHelper, object> content)
        {
            Component.DesignTemplate.InlineContent = content;
            return this;
        }

        /// <summary>
        /// Set Widget Content show in design time.
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public WidgetViewBuilder Design(Action<WidgetHelper> content)
        {
            Component.DesignTemplate.Content = content;
            return this;
        }

        /// <summary>
        ///  Set the Widget Content show in Preivew box
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public WidgetViewBuilder Preview(Action<WidgetHelper> content)
        {
            Component.PreviewTemplate.Content = content;
            return this;
        }

        /// <summary>
        /// Set the Widget Content show in Preivew box
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public WidgetViewBuilder Preview(Func<WidgetHelper, object> content)
        {
            Component.PreviewTemplate.InlineContent = content;
            return this;
        }
    }
}